<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>后台管理模板</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="format-detection" content="telephone=no">
		<link rel="stylesheet" href="../../layui/css/layui.css" media="all" />
		<link rel="stylesheet" href="../../css/global.css" media="all">
		<link rel="stylesheet" type="text/css" href="http://www.jq22.com/jquery/font-awesome.4.6.0.css">
		<link rel="stylesheet" href="../../datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.css">
		<style type="text/css">
			label {
				font-size: 18px;
			}
			
			img {
				margin-right: 10px
			}
			
			.complainwords {
				width: 15%;
				line-height: 27px;
				font-size: 16px;
			}
			
			.handle1 {
				margin-top: 10px;
				/* padding-right: 40px; */
				line-height: 60px;
				float: left;
				clear: both;
				border-right: solid 1px;
				margin-left: 5%;
				width: 255px;
				height: 120px;
			}
			
			.handle2 {
				float: left;
				margin-top: 10px;
				margin-left: 45px;
				line-height: 60px;
				border-right: solid 1px;
				width: 307px;
				height: 120px;
			}
			
			span {
				margin-left: 10px;
				color: gray;
			}
			
			input[type="text"] {
				width: 159px;
				height: 30px;
				border-radius: 5px;
			}
			
			.freezzBeComplained {
				position: relative;
				top: 40px;
				float: left;
				margin-left: 60px;
			}
			
			.hide1,
			.complainContent {
				display: none;
			}
			
			.hide2,
			.inputScore {
				display: none;
			}
			
			.contactBefore {
				position: relative;
				top: 30px;
				float: left;
				margin-left: 60px;
			}
			
			.takeoffBefore {
				position: relative;
				top: 30px;
				float: left;
				margin-left: 50px;
			}
		</style>
	</head>

	<body>
		<div class="layui-layout layui-layout-admin" style="border-bottom: solid 5px #1aa094;">
			<!--头部导航-->
			<div class="layui-header header header-demo"></div>
			<!--左侧导航-->
			<div class="layui-side layui-bg-black" id="admin-side">
			</div>
			<!--右侧具体内容-->
			<div class="layui-body" style="bottom: 0;border-left: solid 2px #1AA094;padding:20px;margin-bottom: 30px" id="admin-body">
				<div class="title">投诉详情</div>
				<hr/>
				<div class="items">
					<div class="item">
						<label class="itemleft">发起人</label><label class="itemright"><img src="../../images/6.jpg" id="headPortraitUrl"><label id="nickname">大灰狼</label></label>
					</div>
					<hr>
					<div class="item">
						<label class="itemleft">被投诉人</label><label class="itemright"><img src="../../images/xiaosong.jpg" id="beComplainUserHeadPortraitUrl"><label id="beComplainUserNickname">大灰狼</label></label>
					</div>
					<hr>
					<div class="item">
						<label class="itemleft">投诉内容</label><label class="itemright complainwords" style="" id="complainContent">态度超恶劣的分行的文本段</label>
					</div>
					<hr>
					<div class="item">
						<label class="itemleft">投诉时间</label><label class="itemright" id="complainTime">2017-7-4 19:03</label>
					</div>
					<hr>
					<div>
						<label class="itemleft" style="float:left;margin-top: 10px;">处理</label>
						<div class="handle1">
							<div>
								<div class="layui-btn layui-btn-warm contactHide contactBefore" id="contact" onclick="Contact()">联络发起人</div><span class="hide1">电话联系发起人</span>
							</div>
							<div class="complainContent1" style="display: none;">发起人电话：
								<lable id="complainContentPhoneNumber">13978212123</lable>
							</div>
						</div>
						<div class="handle2">
							<div>
								<div class="layui-btn layui-btn-danger takeoffHide takeoffBefore" id="takeoff" onclick="Takeoff()">扣除被投诉人信用分</div><span class="hide2">并通知被投诉人</span>
							</div>
							<div class="inputScore"><input type="text" name="" id="score" placeholder="输入分数" style="width: 130px">&nbsp;&nbsp;&nbsp;<label class="layui-btn" style="margin-left:25px" id="submitResult">提交</label></div>
						</div>
						<div class="layui-btn layui-btn-danger freezzBeComplained" id="operation">冻结被投诉人账号</div>
					</div>
				</div>
			</div>
			<!--底部导航-->
			<div class="layui-footer footer footer-demo" id="admin-footer"></div>
			<!--JS模块-->
			<script type="text/javascript" src="../../layui/layui.js"></script>
			<script src="../../js/jquery-1.12.3.min.js"></script>
			<script src="../../js/index.js"></script>
			<script src="../../layui/layui.js"></script>
			<script>
				var data = {
					"code": 200,
					"complain": {
						"id": 12345,
						"beComplainUserId": 75198,
						"nickname": "小白兔",
						"username": "15967179986",
						"headPortraitUrl": "../../images/fems.jpg",
						"complainUserId": 76533,
						"beComplainUserNickname": "大灰狼",
						"beComplainUserHeadPortraitUrl": "../../images/find_1.png",
						"complainTime": "2017-8-8 11:30", //ture是啥玩意
						"complainContent": "没有送到我家楼下",
						"complainState": 26381 //0未完成 1 完成 
					}
				}
				var C1 = window.location.href.split("?")[1];
				var complainid = C1.split("=")[1];
				var beComplainId;
				$(function() {
					$.ajax({
						type: "get",
						url: "/randomdelivery/AdminController/complain/" + complainid,
						dataType: "json",
						contentType: "application/json",
						success: function(data) {
							//alert(JSON.stringify(data))
							complaindetail(data)
						},
						Error: function() {
							alert("服务器出错");
						}
					})

					function complaindetail(data) {
						beComplainId = data.complain.beComplainUserId;
						$("#nickname").text(data.complain.nickname)
						$("#beComplainUserNickname").text(data.complain.beComplainUserNickname)
						$("#complainContentPhoneNumber").text(data.complain.username)
						//alert(data.complain.username)
						//$("#username").text(data.complain.username)
						$("#complainTime").text(new Date(data.complain.complainTime).Format("yyyy-MM-dd hh:mm:ss"))
						$("#headPortraitUrl").attr('src', data.complain.headPortraitUrl);
						$("#beComplainUserHeadPortraitUrl").attr('src', data.complain.beComplainUserHeadPortraitUrl);
						if(parseInt(data.complain.userState) == 0) {
							$("#operation").attr("class", "layui-btn freezzBeComplained");
							$("#operation").text("解封被投诉人账号");
						}
						$("#complainContent").text(data.complain.complainContent)
						//$("#operation").attr('id', data.complain.beComplainUserId)
					}

				})

				function Contact() {
					if($(".complainContent1").css('display') == 'none') {
						$(".complainContent1").css('display', 'block');
						$(".hide1").css('display', 'inline');
						$(".contactHide").removeClass('contactBefore');
					} else {
						$(".hide1,.complainContent1").css('display', 'none');
						$(".contactHide").addClass('contactBefore');
					}

				}

				function Takeoff() {
					if($(".inputScore").css('display') == "none") {
						$(".inputScore").css('display', 'block');
						$(".hide2").css('display', 'inline');
						$(".takeoffHide").removeClass('takeoffBefore');
					} else {
						$(".hide2,.inputScore").css('display', 'none');
						$(".takeoffHide").addClass('takeoffBefore');
					}
				}
				
				$("#submitResult").click(function()
				{
					var element = $("#score");
					/*if(!isNaN(element.val()))
					{
					alert(element.val())
					}*/
					if(!isNaN(element.val())&&Math.floor(element.val())==element.val())
					{
						$.ajax({
							type:"DELETE",
							url:"/randomdelivery/AdminController/deductUserIntegralScore/"+beComplainId+"/"+element.val(),
							async:true,
							success:function(data)
							{
								if(data.code==200)
								{
									alert("扣除成功");
									Takeoff();
								}
								else
								{
									alert("扣除失败")
								}
							}
						});
					}
					else
					{
						alert("请输入一个整数")
					}
				})

				$("#operation").on('click', function() {
					var element = this;
					var info = $(element).text();
					if(info == "冻结被投诉人账号") {
						layui.use('layer', function() {
							var layer = layui.layer;
							layer.confirm('是否要冻结选中被投诉人账号？', {
								icon: 2,
								title: '提示'
							}, function(index) {
								$.ajax({
									type: "DELETE",
									url: "/randomdelivery/AdminController/closeAccount/" + beComplainId,
									async: true,
									dataType: "json",
									contentType: "application/json",
									success: function(data) {
										if(data.code == 200) {
											$(element).attr("class", "layui-btn freezzBeComplained");
											$(element).text("解封被投诉人账号");
											//alert(123)
											layer.msg("冻结成功")
										}
									},
									Error: function() {
										alert("服务器出错");
									}
								})
							})
						})
					}
					else
					{
						layui.use("layer",function()
						{
							var layer = layui.layer;
							layer.confirm("是否解冻被投诉人账号",{
								icon:2,
								title:"提示"
							},function()
							{
								$.ajax({
									type:"GET",
									url:"/randomdelivery/AdminController/openAccount/"+beComplainId,
									async:true,
									success:function(data)
									{
										if(data.code==200)
										{
											$(element).attr("class", "layui-btn layui-btn-danger freezzBeComplained");
											$(element).text("冻结被投诉人账号");
											//alert(456)
											//alert($(element).attr("class"))
											layer.msg("解冻成功")
										}
									}
								});
							})
						})
					}

				});
			</script>
		</div>
	</body>

</html>